Page({
  onLoad({ id }) {
    // 获取通行证
    this.getPassport(id)
  },
  async getPassport(id) {
    // 请求数据接口
    const { data } = await wx.http.get('/visitor/' + id)
    // 渲染通行证
    this.setData({ ...data })
  },
  // 保存二维码图片
  async saveImg() {
    const { path } = await wx.getImageInfo({ src: this.data.url })
    console.log('读取本地地址：', path)
    // 2. 存到手机相册
    await wx.saveImageToPhotosAlbum({ filePath: path })
  },
  onShareAppMessage() {
    return {
      title: '查看通行证',
      path: `/visitor_pkg/pages/passport/index?id=${this.id}`,
      imageUrl: 'https://enjoy-plus.oss-cn-beijing.aliyuncs.com/images/share_poster.png',
    }
  },
})
